{'op' : 'device_create',
'config' : fileof(config) })
+ def xend_domain_device_refresh(self, id, type, idx):
+ return self.xendPost(self.domainurl(id),
+ {'op' : 'device_refresh',
+ 'type' : type,
+ 'idx' : idx })
+
def xend_domain_device_destroy(self, id, type, idx):
return self.xendPost(self.domainurl(id),
{'op' : 'device_destroy',
self.update_domain(dominfo.id)
return val
+ def domain_device_refresh(self, id, type, idx):
+ """Refresh a device.
+
+ @param id: domain id
+ @param idx: device index
+ @param type: device type
+ """
+ dominfo = self.domain_lookup(id)
+ self.refresh_schedule()
+ val = dominfo.device_refresh(type, idx)
+ self.update_domain(dominfo.id)
+ return val
def domain_device_destroy(self, id, type, idx):
"""Destroy a device.
dl.append(dev)
self.devices[type] = dl
+ def refresh_device(self, type, dev):
+ """Refresh a device to a virtual machine.
+
+ @param type: device type
+ @param dev: device
+ """
+ dl = self.devices.get(type, [])
+ if dev in dl:
+ dl.refresh(dev)
+
def remove_device(self, type, dev):
"""Remove a device from a virtual machine.
old_index = self.config.index(old_full_config)
self.config[old_index] = new_full_config
return new_config
+
+ def device_refresh(self, type, idx):
+ """Refresh a device.
+
+ @param type: device type
+ @param idx: device index
+ """
+ dev = self.get_device_by_index(type, idx)
+ if not dev:
+ raise VmError('invalid device: %s %s' % (type, idx))
+ devs = self.devices.get(type)
+ dev.refresh()
+ #self.refresh_device(type, dev)
def device_destroy(self, type, idx):
"""Destroy a device.
d = fn(req.args, {'dom': self.dom.id})
return d
+ def op_device_refresh(self, op, req):
+ fn = FormFn(self.xd.domain_device_refresh,
+ [['dom', 'str'],
+ ['type', 'str'],
+ ['idx', 'str']])
+ val = fn(req.args, {'dom': self.dom.id})
+ return val
+
def op_device_destroy(self, op, req):
fn = FormFn(self.xd.domain_device_destroy,
[['dom', 'str'],
val.append(['index', self.index])
return val
+ def refresh(self):
+ log.debug("Refreshing vbd domain=%d idx=%s", self.controller.dom, self.idx)
+ self.interfaceChanged()
+
def destroy(self, change=0):
"""Destroy the device. If 'change' is true notify the front-end interface.
xm.prog(ProgVbdCreate)
+class ProgVbdRefresh(Prog):
+ group = 'vbd'
+ name = 'vbd-refresh'
+ info = """Refresh a virtual block device for a domain"""
+
+ def help(self, args):
+ print args[0], "DOM DEV"
+ print """
+Refresh a virtual block device for a domain.
+
+ DEV - idx field in the device information
+"""
+
+ def main(self, args):
+ if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
+ dom = args[1]
+ dev = args[2]
+ server.xend_domain_device_refresh(dom, 'vbd', dev)
+
+xm.prog(ProgVbdRefresh)
+
+
class ProgVbdDestroy(Prog):
group = 'vbd'
name = 'vbd-destroy'